Technical Q&AJava 14 - Properties versus methods in automatically generated
|
public void
setDictionaryName( String name ){...}
|
Shows up in the AppleScript dictionary as:
| Properties: <Inheritance> Object [r/o] dictionary name string -- public void foo.setDictionaryName(String) |
I was expecting the dictionary to look like this:
| MyClass: setDictionaryName: public void foo.setDictionaryName(String) setDictionaryName reference parameters string |
Why is this happening?
A: If you have a method that uses the standard
Java bean syntax for property accessor routines (i.e., methods that are in the format setX(), getX(), or isX() where X is a property name), the introspector will assume that the routines are class properties.
The method you declared looks like a routine for
setting the value of the dictionaryName property, so it is interpreted as a property accessor function. As a result, the default behavior for the automatic terminology generator creates an entry in the
dictionary in the property format instead of a method format.
This behavior may actually be preferred since it is a lot easier to script an application as:
set dictionary name of foo 1 to "English Language" |
compared to:
setDictionaryName of foo 1 parameters {"English Language" }
|